﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for TipDogrulama
/// </summary>
public class TipDogrulama
{
    public TipDogrulama()
    {
    }

    public static Boolean IsNumeric(Object pDeger)
    {
        if (pDeger == null || pDeger is DateTime) return false;

        if (pDeger is Int16 || pDeger is Int32 || pDeger is Int64 || pDeger is Decimal || pDeger is Single || pDeger is Double || pDeger is Boolean) return true;

        try
        {
            if (pDeger is string)
                Double.Parse(pDeger as string);
            else
                Double.Parse(pDeger.ToString());

            return true;
        }
        catch 
        { 
            return false; 
        }
    }

    public static Boolean IsInteger(Object pDeger)
    {
        if (pDeger == null || pDeger is DateTime) return false;

        if (pDeger is Int16 || pDeger is Int32 || pDeger is Int64) return true;

        try
        {
            if (pDeger is string)
                Int64.Parse(pDeger as string);
            else
                Int64.Parse(pDeger.ToString());

            return true;
        }
        catch
        {
            return false;
        }
    }

    public static Boolean IsDate(Object pDeger)
    {
        if (pDeger == null) return false;
        try
        {
            if (pDeger is DateTime)
                return true;
            else
                Convert.ToDateTime(pDeger);

            return true;
        }
        catch
        {
            return false;
        }
    }
}

